package com.hospital.controller;

import com.hospital.domain.Doctor;
import com.hospital.domain.Remark;
import com.hospital.service.RemarkService;
import com.hospital.service.impl.RemarkServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/remarks")
public class RemarkController {

    @Autowired
    RemarkService remarkService;


    @GetMapping("/selectRemark")
    public List<Remark> selectRemark(int x){
        List<Remark> remarks = remarkService.selectRemarkByDoctorID(x);
//        System.out.println(remarks);
        return remarks;
    }

    @PostMapping("/addRemark")
    public String addRemark(@RequestBody Remark remark, HttpSession session){

        int userID = (int)session.getAttribute("userID");
        int doctorID = remark.getDoctorID();
        String content = remark.getContent();
        remarkService.addRemarkByUserIDAndDoctorID(userID,doctorID,content);
        return "success";
    }

}
